/*
 * @Author: your name
 * @Date: 2021-02-26 09:22:44
 * @LastEditTime: 2021-02-26 16:58:50
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \web-app\src\router\index.js
 */
import Vue from 'vue'
import VueRouter from 'vue-router'
const Home = () => import(/* webpackChunkName: 'home' */ '@/views/home')
const Catalog = () => import(/* webpackChunkName: 'catalog' */ '@/views/home/catalog')
const Detail = () => import(/* webpackChunkName: 'Detail' */ '@/views/detail')
const User = () => import(/* webpackChunkName: 'User' */ '@/views/user/user')
const Login = () => import(/* webpackChunkName: 'Login' */ '@/views/user/login')
const Reg = () => import(/* webpackChunkName: 'Reg' */ '@/views/user/reg')
const Forget = () => import(/* webpackChunkName: 'Forget' */ '@/views/user/forget')

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: Home,
    children: [
      {
        path: '',
        name: 'catalog',
        component: Catalog,
        props: true
      },
      {
        path: '/index/:catalog',
        name: 'catalog',
        component: Catalog,
        props: true
      }
    ]
  },
  { // 详情页
    path: '/detail/:tid',
    name: 'detail',
    component: Detail,
    props: true
  },
  // 注册登录
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/reg',
    name: 'reg',
    component: Reg
  },
  {
    path: '/forget',
    name: 'forget',
    component: Forget,
    meta: { requiresAuth: true }
  },
  {
    path: '/user',
    name: 'user',
    component: User
  }
]

const router = new VueRouter({
  routes,
  linkExactActiveClass: 'active'
})

export default router
